package CommonsdbutilsTest.MybatisPoject;

import CommonsdbutilsTest.MybatisPoject.MyBatisDao;
import CommonsdbutilsTest.Student;
import CommonsdbutilsTest.poketmoneyDao;

import java.util.Scanner;

public class MybatisTests {
    public static void main(String[] args) throws Exception {
        Student student = new Student();
        poketmoneyDao poketmoneyDao = new poketmoneyDao();
        Scanner scanner = new Scanner(System.in);
        poketmoneyDao.logon();

        while (true){


            System.out.println("欢迎来到学生信息管理系统");
            System.out.println("查询请按1");
            System.out.println("删除请按2");
            System.out.println("更新请按3");
            System.out.println("添加请按4");
            System.out.println("退出请按5");
            int aa = scanner.nextInt();


            switch (aa) {
                case 1:
                    MyBatisDao.select();
//                    List<Student> selectAll = poketmoneyDao.selectAll();
//                    for (Student u  :selectAll){
//                        System.out.println("u = " + u);
//                    }

//                    System.out.println("selectAll.toString() = " + selectAll.toString());
//                    for (Object fruit : selectAll) {
//                        System.out.print(" \t\t\t" + fruit.toString());
//
////                        System.out.print("\t\t\t" + fruit.getPay());
////                        System.out.print("\t\t\t " + fruit.getTime());
////                        System.out.print("\t\t\t " + fruit.getDeposit());
//
//
//                        System.out.println("");
//                    }

//
//                    System.out.println("selectAll = " + selectAll);

                    break;

                case 2:
                    MyBatisDao.delete();
//                    System.out.println("输入你要删除对象的id");
//                    int id = scanner.nextInt();
//                    int delete = poketmoneyDao.delete(id);
//                    System.out.println("delete = " + delete);
                    break;

                case 3:
                        MyBatisDao.update();
//                    System.out.println("输入你要更新对象的id");
//                    int id1 = scanner.nextInt();
//                    System.out.println("将对象的name更新为");
//                    String name1 = scanner.next();
//                    System.out.println("将对象的sex更新为");
//                    String sex1 = scanner.next();
//                    System.out.println("将对象的age更新为");
//                    int age1 = scanner.nextInt();
//                    System.out.println("将对象的department更新为");
//                    String department1 = scanner.next();
//                    student.setSname(name1);
//                    student.setSsex(sex1);
//                    student.setSage(age1);
//                    student.setSdepartment(department1);
//                    student.setSid(id1);
//                    System.out.println("money_javabean = " +  student);
//                    int updated = poketmoneyDao.update( student);
//                    System.out.println("updated = " + updated);
                    break;

                case 4:
                    MyBatisDao.add();
//                    System.out.println("输入你要添加对象的id");
//                    int id2 = scanner.nextInt();
//                    System.out.println("将对象的name新添加为");
//                    String name2 = scanner.next();
//                    System.out.println("将对象的sex新添加为");
//                    String sex2 = scanner.next();
//                    System.out.println("将对象的age新添加为");
//                    int age2 = scanner.nextInt();
//                    System.out.println("将对象的department新添加为");
//                    String department2 = scanner.next();
//
//                    student.setSname(name2);
//                    student.setSsex(sex2);
//                    student.setSage(age2);
//                    student.setSdepartment(department2);
////                    student.setSid(id2);
//                    System.out.println("money_javabean = " +  student);
//                    int insert = poketmoneyDao.insert( student);
//                    System.out.println("insert = " + insert);
                    break;

                case 5:
                    System.out.println("您已经选择退出");

                    break;
                default:
                    throw new IllegalStateException("Unexpected value: " + aa);
            }

            if (aa==5){
                break;
            }



        }
//        MyBatisDao.add();
    }

}
